// Copyright DustedPixels.com 2008. All rights reserved.

package kroff;

import com.dustedpixels.common.base.Repeatable;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class Benchmark {
  private static final int LOOPS = 10000;
  private static final int STEPS = 10000;

  public static void main(String[] args) {
    final Repeatable unit = Repeatables.over(Runnables.newKroffUnit());
    final Repeatable optimisedUnit = new OptimizedKroffUnit();
    final Repeatable halfOptimisedUnit = new HalfOptimizedKroffUnit();
    
    for (int i = 0; i < LOOPS; i++) {
      unit.repeat(STEPS);
    }

    for (int i = 0; i < LOOPS; i++) {
      optimisedUnit.repeat(STEPS);
    }
    
    for (int i = 0; i < LOOPS; i++) {
      halfOptimisedUnit.repeat(STEPS);
    }
    
    long time = System.currentTimeMillis();
    for (int i = 0; i < LOOPS; i++) {
      unit.repeat(STEPS);
    }
    System.out.println("Not optimised: " + (System.currentTimeMillis() - time) + " ms");

    time = System.currentTimeMillis();
    for (int i = 0; i < LOOPS; i++) {
      optimisedUnit.repeat(STEPS);
    }
    System.out.println("Optimised: " + (System.currentTimeMillis() - time) + " ms");

    time = System.currentTimeMillis();
    for (int i = 0; i < LOOPS; i++) {
      halfOptimisedUnit.repeat(STEPS);
    }
    System.out.println("Half optimised: " + (System.currentTimeMillis() - time) + " ms");
  }
}
